<?php
/**
 * Created by PhpStorm.
 * Date: 2016/7/19
 * Time: 15:28
 */
error_reporting(0);
//include '../CommonConstant.php';

define("DB_IP",'localhost');      //Ĭ数据库地址localhost
define("DB_PORT",'3306');         //Ĭ数据库端口3306
define("DB_USER",'root');             //mysql数据库用户名
define("DB_PASS",'');             //mysql数据密码
define("DB_DATABASENAME",'test');     //mysql默认数据库名
define("DB_DEFAULT_TABLENAME",'dual');     //mysql默认表名

//连接mysql_db
function conn_mysql($db_name=DB_DATABASENAME, $server_username=DB_USER, $server_password=DB_PASS, $server_ip=DB_IP, $server_port=DB_PORT){
//    echo "DB_IP=".$server_ip.",DB_PORT=".$server_port;
    $conn_temp = mysql_connect($server_ip.":".$server_port,$server_username,$server_password) or die("Error:connect fialed".mysql_error());
    mysql_query("set names 'utf8'");
    mysql_select_db($db_name,$conn_temp);
    return $conn_temp;
}

function queryRecord($querySentence,$conn){
//    $querySentence = sprintf("select * from %s",DB_DEFAULT_TABLENAME);
    $result_tmep = mysql_query($querySentence,$conn);
//    if ($result_tmep)$count=mysql_fetch_row($result_tmep);
//    else die('query empty');
//    echo "������$count[0]����¼<br/>";

    return $result_tmep;
}


//$conn=conn_mysql();
//$db_table = 'test';
//$query_sql = "select testid,test_name from ".$db_table." ";
//$result = mysql_query($query_sql,$conn);
//while ($row=mysql_fetch_array($result, MYSQL_ASSOC))//��$row=mysql_fetch_assoc($result)�ȼ�
//{
//    echo $row['testid'].",".$row['test_name']."</br>";
//}
